import tkinter as tk
from tkinter import ttk
from PIL import Image, ImageTk
import os

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))

def init_launch_screen(parent, items):
    """
    Initializes and displays the launch screen with title and navigation buttons.
    
    Creates the main launch interface with a title label and buttons to enter the
    application or exit. Uses custom styling for a consistent visual appearance.
    
    Args:
        parent (tk.Widget): The parent container for the launch screen
        items (list): List of pet items (passed for consistency with other screen functions)
    """
    frame = tk.Frame(parent)
    frame.pack(fill=tk.BOTH, expand=True)

    frame.config(bg="#FFD1DC")
    tk.Label(
        frame, 
        text="Electronic Pet Collection", 
        font=("Arial", 24, "bold"),
        bg="#E7BD6E",  
        fg="#7D5A3F",  
        padx=20,
        pady=10
    ).place(relx=0.5, rely=0.3, anchor="center")

    btn_frame = tk.Frame(frame, bg="#FFD1DC")
    btn_frame.place(relx=0.5, rely=0.7, anchor="center")

    style = ttk.Style()
    style.configure(
        "Harmony.TButton",
        font=("Arial", 12, "bold"),
        foreground="#7D5A3F", 
        background="#E7BD6E",
        padding=12, 
        borderwidth=1,
        bordercolor="#D4A76A", 
        relief="solid"
    )
    
    style.map(
        "Harmony.TButton",
        background=[("active", "#D4A76A")],
        foreground=[("active", "#6B4832")]   
    )

    
    ttk.Button(
        btn_frame,
        text="Enter",
        command=lambda: go_to_selection(parent),
        style="Harmony.TButton"
    ).pack(side=tk.LEFT, padx=20)

    ttk.Button(
        btn_frame,
        text="Exit",
        command=parent.quit,
        style="Harmony.TButton"
    ).pack(side=tk.LEFT, padx=20)
    return None

def go_to_selection(parent):
    """
    Navigates from the launch screen to the main selection screen.
    
    Triggers a screen change to display the pet selection interface.
    
    Args:
        parent (tk.Widget): The parent container widget
    """
    from src.ui.tkinter.main_window import show_screen
    show_screen("selection")
    return None